package com.sun.showcase.controller.mall;

import com.sun.showcase.biz.mall.service.MemberLevelService;
import com.sun.showcase.client.domain.mall.MemberLevel;
import com.sun.showcase.client.query.mall.MemberLevelQuery;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value="/mall/memberLevel")
public class MemberLevelController{
	
	@Autowired
	private MemberLevelService memberLevelService;
	
	private Result result = new Result();
	/**
	 * 跳转到MemberLevel管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goMemberLevel")
	public String goMemberLevel() {
		return "mall/memberLevel";
	}
	/**
	 * 跳转到MemberLevel新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleMemberLevel")
	public String handleMemberLevel(@RequestParam(value="id",required=false) Long id , ModelMap map) {
		return "mall/memberLevel_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public MemberLevel showDesc(MemberLevelQuery memberLevelQuery) {
		return memberLevelService.get(memberLevelQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(MemberLevelQuery memberLevelQuery) {
		return memberLevelService.datagrid(memberLevelQuery);
	}
	

	/**
	 * 添加一个MemberLevel
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Result add(MemberLevelQuery memberLevelQuery) {
		memberLevelService.add(memberLevelQuery);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑MemberLevel
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Result edit(MemberLevelQuery memberLevelQuery) {
		memberLevelService.update(memberLevelQuery);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除MemberLevel
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Result delete(MemberLevelQuery memberLevelQuery) {
		memberLevelService.delete(memberLevelQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除MemberLevel
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Result deletePt(MemberLevelQuery memberLevelQuery) {
		memberLevelService.deletePt(memberLevelQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	/**
	 * 全部数据MemberLevel
	 */
	@ResponseBody
	@RequestMapping(value="listAll")
	public Result listAll(MemberLevelQuery memberLevelQuery) {
		List<MemberLevelQuery> list = memberLevelService.listAll(memberLevelQuery);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(list);
		return result;
	}
}
